package com.circle;

import com.circle.view.DocForOutFilePage;
import com.circle.view.DocPage;
import com.circle.view.SetPage;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;

public class App extends JFrame {
    // 全局字体配置
    private static final String FONT_NAME = "微软雅黑";
    private static final int FONT_SIZE_NORMAL = 14;
    private static final Font FONT_NORMAL = new Font(FONT_NAME, Font.PLAIN, FONT_SIZE_NORMAL);

    public App() {
        super("文档管理系统（DCC迁出）");
        // 设置窗口图标
        try {
            // 或者方法2：从资源文件加载（推荐）
            Image icon = new ImageIcon(getClass().getResource("/images/favicon.ico")).getImage();
            setIconImage(icon);
        } catch (Exception e) {
            System.err.println("加载图标失败: " + e.getMessage());
        }

        // 设置全局字体
        setUIFont(new FontUIResource(FONT_NORMAL));
        
        // 设置窗口大小
        setSize(1000, 600);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        // 创建标签页面板
        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.setFont(FONT_NORMAL);
        
        // 添加标签页
        tabbedPane.addTab("内部文件", new DocPage());
        tabbedPane.addTab("外部文件", new DocForOutFilePage());
        tabbedPane.addTab("系统配置", new SetPage());
        
        add(tabbedPane);
        setLocationRelativeTo(null);
    }

    private void setUIFont(FontUIResource f) {
        java.util.Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource) {
                UIManager.put(key, f);
            }
        }
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            App app = new App();
            app.setVisible(true);
        });
    }
}
